package com.renjibo.recycleviewrenovatedemo;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.widget.Toast;

import cn.lemon.view.RefreshRecyclerView;
import cn.lemon.view.adapter.Action;

public class MainActivity extends AppCompatActivity {

    private RefreshRecyclerView refreshRecyclerView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        refreshRecyclerView = (RefreshRecyclerView) findViewById(R.id.refreshRecyclerView);
        refreshRecyclerView.setSwipeRefreshColors(0xFF437845,0xFFE44F98,0xFF2FAC21);
        refreshRecyclerView.setLayoutManager(new LinearLayoutManager(this));
        MyAdapter myAdapter=new MyAdapter(this);
        refreshRecyclerView.setAdapter(myAdapter);
        refreshRecyclerView.setRefreshAction(new Action() {
            @Override
            public void onAction() {
                Toast.makeText(MainActivity.this,"setRefreshAction",Toast.LENGTH_SHORT).show();
                refreshRecyclerView.dismissSwipeRefresh();
                //startActivity(new Intent(MainActivity.this,SecondActivity.class));
            }
        });
        refreshRecyclerView.setLoadMoreAction(new Action() {
            @Override
            public void onAction() {
                Toast.makeText(MainActivity.this,"setLoadMoreAction",Toast.LENGTH_SHORT).show();
                refreshRecyclerView.dismissSwipeRefresh();
            }
        });
//        myAdapter.setHeader(textView); //添加Header
//        myAdapter.setFooter(footer); //添加Footer
    }
}
